\(\int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx\) [2]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 24 \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=-b \cos (x)+\frac {1}{3} b \cos ^3(x)+\frac {1}{3} a \sin ^3(x) \]

[Out]

-b*cos(x)+1/3*b*cos(x)^3+1/3*a*sin(x)^3

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 24, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3168, 2644, 30, 2713} \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=\frac {1}{3} a \sin ^3(x)+\frac {1}{3} b \cos ^3(x)-b \cos (x) \]

[In]

Int[Sin[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

-(b*Cos[x]) + (b*Cos[x]^3)/3 + (a*Sin[x]^3)/3

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2644

Int[cos[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sin[(e_.) + (f_.)*(x_)])^(m_.), x_Symbol] :> Dist[1/(a*f), Subst[Int[
x^m*(1 - x^2/a^2)^((n - 1)/2), x], x, a*Sin[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2] &&
 !(IntegerQ[(m - 1)/2] && LtQ[0, m, n])

Rule 2713

Int[sin[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Dist[-d^(-1), Subst[Int[Expand[(1 - x^2)^((n - 1)/2), x], x], x
, Cos[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[(n - 1)/2, 0]

Rule 3168

Int[sin[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_.), x_Sym
bol] :> Int[ExpandTrig[sin[c + d*x]^m*(a*cos[c + d*x] + b*sin[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d}, x] &&
 IntegerQ[m] && IGtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \int \left (a \cos (x) \sin ^2(x)+b \sin ^3(x)\right ) \, dx \\ & = a \int \cos (x) \sin ^2(x) \, dx+b \int \sin ^3(x) \, dx \\ & = a \text {Subst}\left (\int x^2 \, dx,x,\sin (x)\right )-b \text {Subst}\left (\int \left (1-x^2\right ) \, dx,x,\cos (x)\right ) \\ & = -b \cos (x)+\frac {1}{3} b \cos ^3(x)+\frac {1}{3} a \sin ^3(x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.04 (sec) , antiderivative size = 26, normalized size of antiderivative = 1.08 \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=-\frac {3}{4} b \cos (x)+\frac {1}{12} b \cos (3 x)+\frac {1}{3} a \sin ^3(x) \]

[In]

Integrate[Sin[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

(-3*b*Cos[x])/4 + (b*Cos[3*x])/12 + (a*Sin[x]^3)/3

Maple [A] (verified)

Time = 0.43 (sec) , antiderivative size = 20, normalized size of antiderivative = 0.83

method result size
default \(-\frac {b \left (2+\sin \left (x \right )^{2}\right ) \cos \left (x \right )}{3}+\frac {a \sin \left (x \right )^{3}}{3}\) \(20\)
parts \(-\frac {b \left (2+\sin \left (x \right )^{2}\right ) \cos \left (x \right )}{3}+\frac {a \sin \left (x \right )^{3}}{3}\) \(20\)
risch \(-\frac {3 b \cos \left (x \right )}{4}+\frac {a \sin \left (x \right )}{4}+\frac {b \cos \left (3 x \right )}{12}-\frac {a \sin \left (3 x \right )}{12}\) \(26\)
norman \(\frac {-4 \tan \left (\frac {x}{2}\right )^{2} b +\frac {8 \tan \left (\frac {x}{2}\right )^{3} a}{3}-\frac {4 b}{3}}{\left (1+\tan \left (\frac {x}{2}\right )^{2}\right )^{3}}\) \(34\)
parallelrisch \(\frac {-4 \tan \left (\frac {x}{2}\right )^{2} b +\frac {8 \tan \left (\frac {x}{2}\right )^{3} a}{3}-\frac {4 b}{3}}{\left (1+\tan \left (\frac {x}{2}\right )^{2}\right )^{3}}\) \(35\)

[In]

int(sin(x)^2*(a*cos(x)+b*sin(x)),x,method=_RETURNVERBOSE)

[Out]

-1/3*b*(2+sin(x)^2)*cos(x)+1/3*a*sin(x)^3

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 27, normalized size of antiderivative = 1.12 \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=\frac {1}{3} \, b \cos \left (x\right )^{3} - b \cos \left (x\right ) - \frac {1}{3} \, {\left (a \cos \left (x\right )^{2} - a\right )} \sin \left (x\right ) \]

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="fricas")

[Out]

1/3*b*cos(x)^3 - b*cos(x) - 1/3*(a*cos(x)^2 - a)*sin(x)

Sympy [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 27, normalized size of antiderivative = 1.12 \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=\frac {a \sin ^{3}{\left (x \right )}}{3} - b \sin ^{2}{\left (x \right )} \cos {\left (x \right )} - \frac {2 b \cos ^{3}{\left (x \right )}}{3} \]

[In]

integrate(sin(x)**2*(a*cos(x)+b*sin(x)),x)

[Out]

a*sin(x)**3/3 - b*sin(x)**2*cos(x) - 2*b*cos(x)**3/3

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 20, normalized size of antiderivative = 0.83 \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=\frac {1}{3} \, a \sin \left (x\right )^{3} + \frac {1}{3} \, {\left (\cos \left (x\right )^{3} - 3 \, \cos \left (x\right )\right )} b \]

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="maxima")

[Out]

1/3*a*sin(x)^3 + 1/3*(cos(x)^3 - 3*cos(x))*b

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.04 \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=\frac {1}{12} \, b \cos \left (3 \, x\right ) - \frac {3}{4} \, b \cos \left (x\right ) - \frac {1}{12} \, a \sin \left (3 \, x\right ) + \frac {1}{4} \, a \sin \left (x\right ) \]

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="giac")

[Out]

1/12*b*cos(3*x) - 3/4*b*cos(x) - 1/12*a*sin(3*x) + 1/4*a*sin(x)

Mupad [B] (verification not implemented)

Time = 22.55 (sec) , antiderivative size = 32, normalized size of antiderivative = 1.33 \[ \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx=-\frac {4\,\left (-2\,a\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3+3\,b\,{\mathrm {tan}\left (\frac {x}{2}\right )}^2+b\right )}{3\,{\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )}^3} \]

[In]

int(sin(x)^2*(a*cos(x) + b*sin(x)),x)

[Out]

-(4*(b - 2*a*tan(x/2)^3 + 3*b*tan(x/2)^2))/(3*(tan(x/2)^2 + 1)^3)